﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualPoint.Controls.Models;

namespace VisualPoint.Controls.Actions
{
    public class TextSelectAction : BaseAction
    {

        public override string Name
        {
            get 
            {
                return "Select Text";
            }
        }

        public override string Description
        {
            get 
            {
                return Text;
            }
        }

        public override string Help
        {
            get 
            {
                return "Selects a text in the current open file.";
                
            }
        }

        private string _text;
        public string Text 
        {
            get
            {
                return _text;
            }
            set
            {
                if (_text != value)
                {
                    _text = value;
                    DoPropertyChanged("Text");
                    DoDescriptionChanged();
                }
            }
        }

        public override BaseActionModel CreateModel()
        {
            return new TextSelectActionModel() { Action = this };
        }

         public override void Run()
        {
            VisualPoint.Controls.Environments.Environment.Current.SelectText(Text);
        }

         public override void InitializeNew()
         {
             Text = VisualPoint.Controls.Environments.Environment.Current.GetSelectedText();
         }
    }
}
